<%@page import="org.apache.commons.fileupload.FileItemFactory"%>
<%@page import="java.io.File"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="org.apache.commons.fileupload.FileItem"%>
<%@page import="java.util.Iterator"%>
<%@page import="java.util.List"%>
<%@page import="org.apache.commons.fileupload.servlet.ServletFileUpload"%>
<%@page import="org.apache.commons.fileupload.disk.DiskFileItemFactory"%>
<%@page import="java.io.PrintWriter"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
	<%
	response.setContentType("text/html; charset=UTF-8");
	PrintWriter out1=response.getWriter(); 
	 String rootPath=request.getSession().getServletContext().getRealPath("/")+"/swfupload";
	 //上传操作  
	  FileItemFactory factory = new DiskFileItemFactory();  
	  ServletFileUpload upload = new ServletFileUpload(factory); 
	  upload.setHeaderEncoding("UTF-8");  
	  try{  
	      List items = upload.parseRequest(request);  
	      if(null != items){  
	          Iterator itr = items.iterator();  
	          while(itr.hasNext()){  
	              FileItem item = (FileItem)itr.next();
	              if(item.isFormField()){  
	                 continue;  
	              }else{  
	                   //以当前精确到秒的日期为上传的文件的文件名  
	                  SimpleDateFormat sdf=new SimpleDateFormat("yyyyMMddkkmmss"); 
	                  String path="/swfupload";
	                  File savedFile = new File(rootPath,item.getName());  
	                  item.write(savedFile); 
	                  out1.print("{status:"+0+",message:'"+path+"/"+item.getName()+"'}");
	              }  
	          }  
	      }  
	  }catch(Exception e){  
	      e.printStackTrace();  
	  }
	  
	  //out1.print("{status:"+0+",message:44}");
	%>
</body>
</html>